from django.contrib.auth.models import Permission, ContentType, Group
from rest_framework import serializers


class PermissionSerialzier(serializers.ModelSerializer):
    """
        用户权限表序列化器
    """
    class Meta:
        model=Permission
        fields=[
            'id',
            'name',
            'codename',
            'content_type',
        ]


class GroupSerializer(serializers.ModelSerializer):
    class Meta:
        model = Group
        fields = [
            'id',
            'name',

            # 当前分组，所拥有对权限
            # 新建分组的时候，前端会传来一个列表: [1,2,3,4]
            'permissions',
        ]
